<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <p:growl />

        <ui:define name="content">
            
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages globalOnly="true" errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            
            <p:panel>
            <h:form>
                
                 <p:wizard widgetVar="wiz"  
                   flowListener="#{completedGoodsEntityController.onFlowProcess}">  
      
                <p:tab id="BasicInfo" title="BasicInfo">  
  
                <p:panel header="Enter Basic Product Information">  
              
                <h:messages errorClass="error" style="color:#D20005"/>  
                  
                <h:panelGrid columns="2" columnClasses="label, value" styleClass="grid">  
                    <h:outputText value="Product Name: *" />  
                    <p:inputText required="true" label="productName"  
                            value="#{completedGoodsEntityController.selected.productName}" 
                            validator ="#{completedGoodsEntityController.validateMaterialName}"/> 
                    
                     <h:outputText value="Weight Per Bar(gram): *" />  
                     <p:inputText required="true" label="weightPerBar"  
                            value="#{completedGoodsEntityController.selected.weightPerBar}" /> 
                     
                     <h:outputText value="Shelf Life(month): *" />  
                     <p:inputText required="true" label="shelfLife"  
                            value="#{completedGoodsEntityController.selected.shelfLife}" />  
                    
                      
                   
                </h:panelGrid>  
            </p:panel>  
        </p:tab>  
                     
         <p:tab id="productionPacking" title="Production and Packing">  
            <p:panel header="Information related to Production and Packng">  
              
                <h:messages errorClass="error" style="color:#D20005"/>  
                  
                <h:panelGrid columns="2" columnClasses="label, value">  
                    <h:outputText value="Capacity Per Minute(bar): " />  
                    <p:inputText value="#{completedGoodsEntityController.selected.capacityPerMin}" />  
                      
                    <h:outputText value="Bars Per Display Box(bar): " />  
                    <p:inputText value="#{completedGoodsEntityController.selected.barsPerBox}" />  
                      
                    <h:outputText value="Boxes Per Shipping Case(boxes): " />  
                    <p:inputText value="#{completedGoodsEntityController.selected.boxesPerCase}" />  
                      
                    
                </h:panelGrid>  
            </p:panel>  
        </p:tab>  
        
         <p:tab id="bom" title="Bill Of Material">  
            <p:panel header="Generate BOM for This Product" id="createBOM">  
              
                <h:messages errorClass="error" style="color:#D20005"/>  
                
                               
                <p:pickList value="#{completedGoodsEntityController.rmsPickList}"  
                             var="item"  
                            itemLabel="#{item}"  
                            itemValue="#{item}">
                    <f:facet name="sourceCaption">All Raw Materials List</f:facet>  
                    <f:facet name="targetCaption">Raw Materials Selection </f:facet>
                </p:pickList>
                
                <p:commandButton action="#{completedGoodsEntityController.updateBOM}"
                                 value="Select Finish"
                                 update="@form:createBOM"/>
                <br />
                <h:outputText value ="Please fill up the BOM Detail." style="color:green" rendered="#{completedGoodsEntityController.bomMaterialList.size()>0}"/> 
                
                <p:dataTable value="#{completedGoodsEntityController.bomMaterialList}" var="item" rendered="#{completedGoodsEntityController.bomMaterialList.size()>0}"
                                     style="text-align: center"
                                     paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                     rowsPerPageTemplate="5,10,15">
                                  
                                     

                            
                            <p:column sortBy="#{item.rawMaterial.productName}">
                                <f:facet name="header">
                                    <h:outputText value="Raw Material Name"/>
                                </f:facet>
                                <h:outputText value="#{item.rawMaterial.productName}"/>
                            </p:column> 
                            
                             <p:column sortBy="#{item.bomWeight}">
                                <f:facet name="header">
                                    <h:outputText value="Raw Material Weight (kg)"/>
                                </f:facet>
                                <h:inputText value="#{item.bomWeight}"/>
                            </p:column> 
                            
                             
                            
                           
                 </p:dataTable>   
                  
                
            </p:panel>  
        </p:tab>  
        
            <p:tab id="confirm" title="Confirmation">  
            <p:panel header="Confirmation">  
              
                <p:growl id="growl" sticky="true" showDetail="true"/>  
              
                <h:panelGrid id="confirmation" columns="2">  
                    <h:outputText value="Product Name: " />  
                    <h:outputText  
                            value="#{completedGoodsEntityController.selected.productName}" style="color:royalblue"/>  
                    
                     <h:outputText value="Weight Per Bar(gram): " />  
                     <h:outputText 
                            value="#{completedGoodsEntityController.selected.weightPerBar}" style="color:royalblue"/> 
                     
                     <h:outputText value="Shelf Life(month): " />  
                     <h:outputText 
                            value="#{completedGoodsEntityController.selected.shelfLife}" style="color:royalblue"/>  
                    <h:outputText value="Capacity Per Minute(bar): " />  
                    <h:outputText value="#{completedGoodsEntityController.selected.capacityPerMin}" style="color:royalblue"/>  
                      
                    <h:outputText value="Bars Per Display Box(bar): " />  
                    <h:outputText value="#{completedGoodsEntityController.selected.barsPerBox}" style="color:royalblue"/>  
                      
                    <h:outputText value="Boxes Per Shipping Case(boxes): " />  
                    <h:outputText value="#{completedGoodsEntityController.selected.boxesPerCase}" style="color:royalblue" /> 
                    
                    
                </h:panelGrid> 
                
                 <br />
                <h:outputText value ="Bill OF Material" style="color:green" rendered="#{completedGoodsEntityController.bomMaterialList.size()>0}"/> 
                
                <p:dataTable value="#{completedGoodsEntityController.bomMaterialList}" var="item" rendered="#{completedGoodsEntityController.bomMaterialList.size()>0}"
                                  
                             style="text-align: center"
                                     paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                     rowsPerPageTemplate="5,10,15">
                                  
                                     

                            
                            <p:column sortBy="#{item.rawMaterial.productName}">
                                <f:facet name="header">
                                    <h:outputText value="Raw Material Name"/>
                                </f:facet>
                                <h:outputText value="#{item.rawMaterial.productName}"/>
                            </p:column> 
                            
                             <p:column sortBy="#{item.bomWeight}">
                                <f:facet name="header">
                                    <h:outputText value="Raw Material Weight (kg)"/>
                                </f:facet>
                                <h:outputText value="#{item.bomWeight}"/>
                            </p:column> 
                            
                             
                            
                           
                 </p:dataTable>   
                  
               <p:commandButton value="Create" update="growl"   
                            action="#{completedGoodsEntityController.create}"/> 
              
            </p:panel>  
        </p:tab> 
        
          
                     
                
                
                 
                 
                 </p:wizard>
                
                
                
                
                


            </h:form>
            </p:panel>
        </ui:define>
    </ui:composition>

</html>
